package com.lwww.infinitechat.authenticationservice.controller;

import com.lwww.infinitechat.authenticationservice.common.Result;
import com.lwww.infinitechat.authenticationservice.service.CommonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/user/common")
@Slf4j
public class CommonController {
    @Autowired
    private CommonService commonService;


//    /**
//     * 发送验证码
//     * @param request
//     * @return
//     */
//    @GetMapping("/sms")
//    public Result<CommonResponse> sendCode(CommonRequest request) throws Exception {
//        log.info("发送验证码:{}",request);
//        CommonResponse response=commonService.sendCode(request);
//        return Result.success(response);
//    }

    /**
     * 发送验证码
     * @param targetEmail
     * @return
     */
    @GetMapping("/getCode")
    public Result<String> mail(@RequestParam String targetEmail,@RequestParam String phone){
        log.info("发送邮件:{}",targetEmail);
        commonService.sendMail(targetEmail,phone);
        return Result.success("邮件发送成功");
    }

}
